<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp" %> 

 
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
    <title>采购项目${name}</title>
    <%@ include file="/WEB-INF/component/commonCSS.jsp" %> 
    <style type="text/css">
    	div.box-body {
    		margin-top:7px;
    	}
    </style>
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
	<input id="opType" type="hidden" value="<%= request.getParameter("opType") %>" />
    <section class="content-header">
        <h1>采购项目${name}</h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
            <li class="active"><a href="#">招标采购管理</a></li>
            <li class="active"><a href="#">采购项目管理</a></li>
            <li class="active"><a href="#">招标项目管理</a></li>
        </ol>
    </section>
    <section class="content">
       <form id="form" action="${ctx}/bidProject/dataEdit.html" method="post" class="form-horizontal" >
            	<input type="hidden" id="projId" name="projId" value="${bidProject.projId}">
    	      <div class=" box box-success">
                <div class="box-body">
                    <div class="form-group form-group-xs">
                        <label for="inputTextAlter4" class="col-sm-2 text-right"><span class="required">*</span>项目编号：</label>
                        <div class="col-sm-3 text-left">
                           	<input class="form-control" id="projCode" name="projCode" readonly="readonly" placeholder="项目编号" type="text" value="${bidProject.projCode }" maxlength="100">
                        </div>
                        <label for="inputTextAlter4" class="col-sm-3 text-right"><span class="required">*</span>项目名称：</label>
                        <div class="col-sm-3 text-left">
                           	<input class="form-control" id="name" name="name" placeholder="项目名称" type="text" value="${bidProject.name }" maxlength="120">	
                        </div>
                    </div>
                    
                    <div class="form-group form-group-xs">
                       <label for="inputTextAlter4" class="col-sm-2 text-right"><span class="required">*</span>项目简介：</label>
                        <div class="col-sm-9 text-left">
                        	<textarea id="projIntro" name="projIntro" class="form-control" placeholder="项目简介(最多2000个字)" >${bidProject.projIntro}</textarea>
                        </div>
                    </div>
                    
                    <div class="form-group form-group-xs">
                    	<label for="inputTextAlter4" class="col-sm-2 text-right"><span class="required">*</span>项目类型：</label>
                       	<div class="col-sm-3 text-left">
                           	<select class="form-control" name="projCat" id="projCat" disabled="disabled">
                        			<option value="${ds.dicCode}">${ds.dicName}</option>
                          	</select>
                       	</div>
                       	<label for="inputTextAlter4" class="col-sm-3 text-right">备注：</label>
                        <div class="col-sm-3 text-left">
                           	<input class="form-control" id="remark" name="remark" placeholder="备注" type="text" value="${bidProject.remark }" maxlength="120">
                        </div>
                    </div>
                    <div class="form-group form-group-xs">
                    	<label for="inputTextAlter4" class="col-sm-2 text-right"><span class="required">*</span>采购开始日期：</label>
                        <div class="col-sm-3 text-left">
                           	<input class="form-control" id="starttime" name="starttime" type="text" placeholder="采购开始日期" value="${bidProject.starttime }"
                           	data-date-fmt="yyyy-MM-dd" onFocus=" WdatePicker({maxDate:'#F{$dp.$D(\'endtime\')}'})" />	
                        </div>
                    	<label for="inputTextAlter4" class="col-sm-3 text-right"><span class="required">*</span>采购结束日期：</label>
                        <div class="col-sm-3 text-left">
                           	<input class="form-control" id="endtime" name="endtime" type="text" placeholder="采购结束日期" value="${bidProject.endtime }"
                           	data-date-fmt="yyyy-MM-dd" onFocus=" WdatePicker({minDate:'#F{$dp.$D(\'starttime\')}'})"/> 
                        </div>
                    </div>
                    
                    <div class="form-group form-group-xs group-info">
                    	<label for="inputTextAlter4" class="col-sm-2 text-right">密码个数：</label>
                        <div class="col-sm-3 text-left">
                        		<input class="form-control" id="passwordCount" name="passwordCount" <c:if test="${!empty bidProject.passwordCount }">readonly="readonly"</c:if> value=" ${bidProject.passwordCount ==null ? '2' :bidProject.passwordCount }"  maxlength="5">
                        </div>
                    </div>      
                </div>
                <div class="box-footer text-center">
                	<button type="button" class="btn btn-success btn-sm" onclick="dataEdit();">保  存</button>
                    <a href="${ctx}/bidProject/toList.html" class="btn btn-danger btn-sm">返  回</a>
                </div>            
            </div>
        </form>
    </section>
    <%@ include file="/WEB-INF/component/commonJS.jsp" %>
    <script type="text/javascript">
    
    //保存
	    function dataEdit() {
	        if (!validate()) {
	            return;
	        } 
	        $.HN.message.confirm("确定保存吗？", "提示信息", "确定").on(function(e) {
        		if (e) {
	        $("#form").ajaxSubmit({ 
	        	url:"${ctx}/bidProject/saveOrUpdate.html",
	            dataType : "json",
	            timeout: 10000,
	            success : function(result) {
	                if (result.success) {
	                    $.HN.message.alert("保存成功！", "消息", "success", function() {
	                        document.location = "${ctx}/bidProject/toList.html";
	                    });
	                } else {
	                    $.HN.message.alert(result.msg || "保存失败！", "消息", "error");
	                   
	                }
	            }
	        });
        		}
        	});
	    }
    
        /* $(document).ready(function() {
        	var opType = $("#projId").val() || "";
        	if (opType == "") {
        		$("#form input[type='text']").val("");
        		$("#form select").val("");
        		$("#form textarea").val("");
        	} 
        }); */
        
      //校验
        function validate() {
        	
        	var projCode = $.trim($("#projCode").val());
        	if (projCode == null || projCode == "") {
        		$.HN.message.alert("项目编号不能为空！", "消息", "error");
        		return false;
        	}else if(projCode.length > 100){
        		$.HN.message.alert("项目编号填写错误！", "消息", "error");
        		return false;
        	} else if (!/^[A-Za-z0-9]+$/.test(projCode)) {
        		$.HN.message.alert("项目编号只能输入英文和数字！", "消息", "error");
        		return false;
        	}
        	
        	var name = $.trim($("#name").val());
        	if (name == null || name == "") {
        		$.HN.message.alert("项目名称不能为空！", "消息", "error");
        		return false;
        	}else if(name.length > 120){
        		$.HN.message.alert("项目名称太长！", "消息", "error");
        		return false;
        	}
        	
        	var projIntro = $.trim($("#projIntro").val());
            if (projIntro == null || projIntro == "") {
                $.HN.message.alert("项目简介不能为空！", "消息", "error");
                return false;
            }else if(projIntro.length > 2000){
            	$.HN.message.alert("项目简介太长！", "消息", "error");
                return false;
            }
         
        	var starttime = $.trim($("#starttime").val());
    		if (starttime == null || starttime == "") {
    			$.HN.message.alert("请选择采购开始日期！", "消息", "warn");
    			return false;
    		}
    		var endtime = $.trim($("#endtime").val());
    		if (endtime == null || endtime == "") {
    			$.HN.message.alert("请选择采购结束日期！", "消息", "warn");
    			return false;
    		}
    		var passwordCount = $.trim($("#passwordCount").val());
        	if (passwordCount > 5) {
        		$.HN.message.alert("最多5个密码！", "消息", "error");
        		return false;
        	}
    		
        	
            return true;
        }
        
       
        
    </script>
</body>
</html>